<?php
/**
 * Created by PhpStorm.
 * User: liziang
 * Date: 2019/1/4
 * Time: 11:41
 */
namespace App\Admin\Controllers;
use App\Http\Controllers\Controller;
use App\Models\PlayerOrder;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use Encore\Admin\Grid;
use Illuminate\Http\Request;
use \Illuminate\Support\Facades\Input;
use App\Admin\Extra\Search\Html;
class PlayerOrderController extends Controller
{

    public function anyListAccount()
    {
        $req_param = $req_param = Input::all();
        //OrderForm::getAccountByName();
        return Admin::content(function (Content $content) use ($req_param) {

            $content->header('player order');
            $content->description('订单列表--单个玩家具体订单');

            $content->row(Html::append([
                Html::input('OrderSerial', 'OrderSerial', url()->current()),
                Html::button('GO', url()->current(), 'search-filter'),
                Html::sjs(url()->current())
            ]));

            $area_data = \App\Models\Area::areaSelectData(0);
            $grid = Admin::grid(PlayerOrder::class, function (Grid $grid)use ($area_data) {

                $grid->model()->where('deleted_at', 0);
                $grid->actions(function ($actions) {
                    $actions->disableDelete();
                    $actions->disableEdit();
                   $actions->append('<a href="' . url('admin/areaorder/detail?CooperatorOrderSerial=') . $actions->row->CooperatorOrderSerial . '"><i class="glyphicon glyphicon-eye-open"></i></a>');
                });

                // 第一列显示id字段，并将这一列设置为可排序列
                $grid->column('OrderSerial');
                $grid->model()->orderBy('OrderSerial', 'DESC');

                // 第二列显示title字段，由于title字段名和Grid对象的title方法冲突，所以用Grid的column()方法代替
                $grid->column('CooperatorOrderSerial');
                $grid->column('cp_player_id');
                $grid->column('OrderMoney');
                $grid->updated_at('updated-cur-time');
                // $grid->column('MerchandiseName');
                $grid->column('cp_product_id');
                $grid->column('prop_name');
                $grid->game_rmb('Game RMB')->display(function($value){
                    return "￥". $value ;
                });
                $grid->game_dollar('Dollar')->display(function($value){
                    return '$'. $value ;
                });


                $grid->filter(function ($filter) use($area_data) {

                    $filter->like('OrderSerial', 'OrderSerial')->placeholder('');
                    $filter->equal('area', 'Area')->select($area_data);
                });
            });
            $content->row($grid->render());
        });

    }
}